package com.googlecode.imanager.client.style.listener;

import com.googlecode.imanager.client.bridge.style.IBackground;
import com.googlecode.imanager.client.bridge.style.IBorder;
import com.googlecode.imanager.client.bridge.style.IFont;
import com.googlecode.imanager.client.bridge.style.IOpacity;
import com.googlecode.imanager.client.bridge.style.IStyle;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public abstract class StyleAttribute<T> {
    
    public static final StyleAttribute<IFont> FONT = new StyleAttribute<IFont>(){
        
        @Override
        public IFont getAttributeValue(IStyle style) {
            return style.getFont();
        }

        @Override
        public String toString() {
            return "FONT";
        }

        @Override
        public Class<IFont> getAttributeType() {
            return IFont.class;
        }
        
    };
    
    public static final StyleAttribute<IBorder> BORDER_LEFT = new StyleAttribute<IBorder>() {

        @Override
        public IBorder getAttributeValue(IStyle style) {
            return style.getBorderLeft();
        }

        @Override
        public String toString() {
            return "BORDER_LEFT";
        }

        @Override
        public Class<IBorder> getAttributeType() {
            return IBorder.class;
        }
        
    };
    
    public static final StyleAttribute<IBorder> BORDER_TOP = new StyleAttribute<IBorder>() {
        
        @Override
        public IBorder getAttributeValue(IStyle style) {
            return style.getBorderTop();
        }

        @Override
        public String toString() {
            return "BORDER_TOP";
        }
        
        @Override
        public Class<IBorder> getAttributeType() {
            return IBorder.class;
        }
        
    };
    
    public static final StyleAttribute<IBorder> BORDER_RIGHT = new StyleAttribute<IBorder>(){
        
        @Override
        public IBorder getAttributeValue(IStyle style) {
            return style.getBorderRight();
        }

        @Override
        public String toString() {
            return "BORDER_RIGHT";
        }
        
        @Override
        public Class<IBorder> getAttributeType() {
            return IBorder.class;
        }
        
    };
    
    public static final StyleAttribute<IBorder> BORDER_BOTTOM = new StyleAttribute<IBorder>(){
        
        @Override
        public IBorder getAttributeValue(IStyle style) {
            return style.getBorderBottom();
        }

        @Override
        public String toString() {
            return "BORDER_BOTTOM";
        }
        
        @Override
        public Class<IBorder> getAttributeType() {
            return IBorder.class;
        }
        
    };
    
    public static final StyleAttribute<IBackground> BACKGROUND = new StyleAttribute<IBackground>(){
        
        @Override
        public IBackground getAttributeValue(IStyle style) {
            return style.getBackground();
        }

        @Override
        public String toString() {
            return "BACKGROUND";
        }

        @Override
        public Class<IBackground> getAttributeType() {
            return IBackground.class;
        }
        
    };
    
    public static final StyleAttribute<IOpacity> OPACITY = new StyleAttribute<IOpacity>() {
        
        @Override
        public IOpacity getAttributeValue(IStyle style) {
            return style.getOpacity();
        }

        @Override
        public String toString() {
            return "OPACITY";
        }

        @Override
        public Class<IOpacity> getAttributeType() {
            return IOpacity.class;
        }
        
    };
    
    public static final StyleAttribute<IStyle> ALL = new StyleAttribute<IStyle>() {
        
        @Override
        public IStyle getAttributeValue(IStyle style) {
            return style;
        }

        @Override
        public String toString() {
            return "ALL";
        }

        @Override
        public Class<IStyle> getAttributeType() {
            return IStyle.class;
        }
        
    };
    
    private StyleAttribute(){
    }
    
    public abstract T getAttributeValue(IStyle style);
    
    public abstract Class<T> getAttributeType();
    
}
